<template>

    <div>
        <div style=" margin-left: 60px;margin-top: 20px;">
            <el-card style="margin-top: 20px;width: 90%;height: 80px;">
                <el-input style="float: left;width: 300px" v-model="inAdvInfo" placeholder="招商咨询"></el-input>
                <el-input style="float: left;width: 300px;margin-left: 40px;" v-model="inAdvCompany" placeholder="项目公司"></el-input>
                <div>
                    <el-button style="float: right" type="primary" @click="reset()">重置</el-button>
                    <el-button style="float: right; margin-right: 30px" type="primary" @click="findAll()">查询
                    </el-button>
                </div>
            </el-card>
        </div>
        <div>
            <el-card style="margin-top: 20px;margin-left: 40px;width: 90%;">
                <div slot="header" class="clearfix">
                    <span>招商咨询数据列表</span>
                    <div class="e2" style="float: right">
                        <el-button type="primary" size="mini" style="margin-right: 10px"
                            @click="$router.push('/addInvestmentAdvisory')">
                            添加招商咨询
                        </el-button>
                        <!-- <el-button type="primary" size="mini" style="margin-right: 10px">批量操作</el-button> -->
                    </div>
                </div>
                <div>
                    <el-table ref="multipleTable" :data="investmentAdvisoryList" tooltip-effect="dark"
                        style="width: 100%">
                        <!-- <el-table-column type="selection" width="55"> </el-table-column> -->
                        <el-table-column prop="inAdvNumber" label="编号" width="120">
                        </el-table-column>
                        <el-table-column prop="inAdvInfo" label="招商咨询" width="120">
                        </el-table-column>
                        <el-table-column prop="inAdvTitle" label="标题" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="inAdvCompany" label="项目公司" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="inAdvTime" label="时间" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="inAdvState" label="状态" show-overflow-tooltip>
                            <template slot-scope="scope">
                                <div v-if="scope.row.inAdvState == '1'">
                                    已发布
                                </div>
                                <div v-else-if="scope.row.inAdvState == '2'">
                                    未发布
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column label="图片">
                            <template slot-scope="scope">
                                <img :src=scope.row.inAdvPhoto style="height: 100px;">
                            </template>
                        </el-table-column>
                        <el-table-column label="操作">
                            <template slot-scope="scope">
                                <el-button type="text" @click="update(scope.row)">编辑</el-button>
                                <el-button type="text" @click="del(scope.row)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </el-card>
        </div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            investmentAdvisoryList: [],
            inAdvInfo: '',
            inAdvCompany:''
        }
    },
    created() {
        this.findAll()
    },
    methods: {
        reset() {
            this.inAdvInfo = '',
            this.inAdvCompany = '',
            this.findAll()
        },
        del(row) {
            this.$axios
                .get("villageinvestment/investment-advisory/delInvestmentAdvisory", {
                    params: {
                        id: row.id,
                    },
                })
                .then(res => {
                    if (res.data.code == 20000) {
                        console.log("成功")
                        this.findAll()
                    } else {
                        this.error = res.data.data.error
                        this.$message({
                            type: 'error',
                            message: this.error
                        })
                    }
                });
        },
        update(row) {
            this.$router.push({ path: '/updateInvestmentAdvisory', query: { paramName: row } })
        },
        findAll() {
            this.$axios
                .get("villageinvestment/investment-advisory/findInvestmentAdvisory",{
                    params: {
                        inAdvInfo: this.inAdvInfo,
                        inAdvCompany: this.inAdvCompany
                    },
                })
                .then(res => {
                    if (res.data.code == 20000) {
                        console.log("成功")
                        this.investmentAdvisoryList = res.data.data.investmentAdvisoryList
                        console.log(this.investmentAdvisoryList)
                    } else {
                        this.error = res.data.data.error
                        this.$message({
                            type: 'error',
                            message: this.error
                        })
                    }
                });
        },
    }
}
</script>
<style scoped>
</style>